package com.ellison.demo.common.config;

import ch.qos.logback.classic.pattern.ClassicConverter;
import ch.qos.logback.classic.spi.ILoggingEvent;
import lombok.SneakyThrows;
import org.springframework.stereotype.Component;

import java.net.InetAddress;

/**
 * IP 配置
 *
 * @author Ellison_Pei
 * @date 2021/10/25 10:59
 * @since 1.0
 **/
@Component
public class IpConvert extends ClassicConverter {
    @SneakyThrows
    @Override
    public String convert(ILoggingEvent event) {
        // 获取本地IP
        InetAddress localHost = InetAddress.getLocalHost();
        return localHost.getHostAddress();
    }
}
